package abc.com.abc.utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLiteHelper extends SQLiteOpenHelper {
    private static final int DB_VERSION=2;
    public static String DB_NAME ="JXZN.db";
    public static final String U_USERINFO = "tb_userinfo";//个人资料
    public static final String U_MSG = "tb_message";//留言信息表

    public SQLiteHelper(Context context) {
        super(context, DB_NAME, null, DB_VERSION);

    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //创建个人信息表
        db.execSQL("CREATE TABLE "+U_USERINFO+"("+
                "_id INTEGER PRIMARY KEY AUTOINCREMENT,"
                +"userName VARCHAR(20),"//用户名
                +"name VARCHAR(20), "//姓名
                +"carModel VARCHAR(20),"//车型
                +"jiakao VARCHAR(20)," //科目几
                +"jiaolian VARCHAR(20),"//教练
                +"phone VARCHAR(20)"//手机号
                +
                ")");
        //创建消息表
        db.execSQL("CREATE TABLE "+U_MSG+"("+
                "_id INTEGER PRIMARY KEY AUTOINCREMENT,"
                +"userName VARCHAR(20),"//用户名
                +"receiver VARCHAR(20), "//接收者
                +"msg VARCHAR(50)"+//信息
                ")");


    }
/*当数据库版本号增加时候才调用这个方法*/
    @Override
    public void onUpgrade(SQLiteDatabase db, int i, int i1) {
        db.execSQL("DROP TABLE IF EXISTS "+ U_USERINFO);
        db.execSQL("DROP TABLE IF EXISTS "+ U_MSG);
        onCreate(db);

    }
}
